{% extends "base.html" %}{% load bootstrap3 %}

{% block top_nav %}
<ul class="nav navbar-nav navbar-right">
  <li>
    <a href="{% url 'admin:index' %}">Admin</a>
  </li>
  <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Create <b class="caret"></b></a>
    <ul class="dropdown-menu">
      <li>
        <a href="{% url 'post_new' post_type='post' %}"><i class="icon-edit"></i> Post</a>
      </li>
      <li>
        <a href="{% url 'post_new' post_type='image' %}"><i class="icon-camera"></i> Image</a>
      </li>
      <li>
        <a href="{% url 'post_new' post_type='video' %}"><i class="icon-play-circle"></i> Video</a>
      </li>
      <li>
        <a href="{% url 'post_new' post_type='quote' %}"><i class="icon-user"></i> Quote</a>
      </li>
      <li>
        <a href="{% url 'post_new' post_type='music' %}"><i class="icon-music"></i> Music</a>
      </li>
    </ul>
  </li>
</ul>
{% endblock %}

{% block content %}
    {% for post in posts_list %}
      <h2><a href="{% url 'post' slug=post.slug %}">{{ post.title }}</a></h2>
      {% if post.post_type == 'BlogPost' %}
        <p>{{ post.body|truncatewords:20 }}</p>
      {% endif %}
      {% if post.post_type == 'Video' %}
        {{ post.embed_code|safe }}
      {% endif %}
      {% if post.post_type == 'Image' %}
        <p><img src="{% url 'image_file' slug=post.slug %}" width="100px" height="100px" /><p>
      {% endif %}
      {% if post.post_type == 'Quote' %}
        <blockquote>{{ post.body|truncatewords:13 }}</blockquote>
        <p>{{ post.author }}</p>
      {% endif %}
      <p>
        {{ post.created_at }} |
        {% with total=post.comments|length %}
            {{ total }} comment{{ total|pluralize }}
        {% endwith %}
      </p>
      <hr />
    {% endfor %}

    {% bootstrap_pagination page_obj %}
{% endblock %}
